package tests.mytest;

import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

public abstract class ElementTreeWalker {

	protected final void walk(Node parent) {
		
		if(parent instanceof Element) {
			processStart(parent);
			NodeList children = parent.getChildNodes();
			for (int i=0; i<children.getLength(); i++) {
				Node child = children.item(i);
				walk(child);
			}		
			processEnd(parent);
		}

	}

	protected abstract void processStart(Node node);

	protected abstract void processEnd(Node node);
	
	
	
}
